/**
 * 
 */
package es.cloudcast.server.persistence.dao.jdo;

import java.io.Serializable;
import java.util.List;

import es.cloudcast.server.model.BasicModel;
import es.cloudcast.server.persistence.PersistenceException;
import es.cloudcast.server.persistence.dao.AdvancedQueryDAO;
import es.cloudcast.server.persistence.jdo.action.ActionProcessor;
import es.cloudcast.server.persistence.jdo.action.basic.ExecuteSelectSQLAction;
import es.cloudcast.server.persistence.jdo.action.basic.ExecuteUpdateSQLAction;

/**
 * JDO implementation for {@link AdvancedQueryDAO}
 * 
 * @see AdvancedQueryDAO
 * @author Samuel García Martínez <in0de>
 *
 */
public class AdvancedJDOQueryDAO <T extends BasicModel, PK extends Serializable>
				extends BasicJDOQueryDAO<T, PK> implements AdvancedQueryDAO<T, PK> {

	public AdvancedJDOQueryDAO(PersistenceManagerFactory PMF) {
		super(PMF);
	}
	
	/*
	 * (non-Javadoc)
	 * @see es.cloudcast.persistence.dao.AdvancedQueryDAO#executeSelectSQL(java.lang.String)
	 */
	@SuppressWarnings("unchecked")
	public List<T> executeSelectSQL(String sql) throws PersistenceException {
		return (List<T>) ActionProcessor.process(new ExecuteSelectSQLAction(persistentClass, sql), PMF);
	}

	/*
	 * (non-Javadoc)
	 * @see es.cloudcast.persistence.dao.AdvancedQueryDAO#executeUpdateSQL(java.lang.String)
	 */
	public Integer executeUpdateSQL(String sql) throws PersistenceException {
		return (Integer) ActionProcessor.process(new ExecuteUpdateSQLAction(persistentClass, sql), PMF);
	}
	
}
